// Learn TypeScript:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;
import wxOpenData from './wx/wx_opendata'
import app_data from './app_data';
import MainScene from './main_scene';
 

declare const pomelo;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Label)
    scoreLabel: cc.Label = null;

 
    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

  

    onRetryGame(){  
        console.log("reset");
        MainScene.getInst().resetGame();
        this.node.active=false;
    }
    onEnable(){
        var score=app_data.score
        if(window["wx"]){
            wxOpenData.wxPostMessageToSubDomain({
                action:wxOpenData.WxDomainAction.UpdateAndFetchFriend,
                data:score
            });
        }
        this.scoreLabel.string=""+score;
        pomelo.request('game.game_handler.updateScore', {score:score});
    }
   
}
